<?php
error_reporting(E_ALL ^ E_NOTICE);

include './db.php';

//$sql = "select * from dish;";

//$ok = $sqls->execute();
//var_export($sqls->fetchAll());

$n = $_GET['username'];
$p = $_GET['pwd'];

if (isset($n) && isset($p)) {
    $sql = "select * from user where user_name='$n'";
    $sqls = $conn->prepare($sql);
    $ok = $sqls->execute();

//    if ($ok) {
//        $item = $sqls->fetch();
//        if ($item != false) {
//            if ($item['password'] == $p) {
//                echo "登录成功";
//            } else {
//                echo "密码错误";
//            }
//
//        } else {
//            echo "用户名不存在";
//        }
//
//    }
}

?>

<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <!-- 上述3个meta标签*必须*放在最前面，任何其他内容都*必须*跟随其后！ -->
    <title>Bootstrap 101 Template</title>

    <!-- Bootstrap -->
    <link href="./css/bootstrap.min.css" rel="stylesheet">

    <!-- HTML5 shim 和 Respond.js 是为了让 IE8 支持 HTML5 元素和媒体查询（media queries）功能 -->
    <!-- 警告：通过 file:// 协议（就是直接将 html 页面拖拽到浏览器中）访问页面时 Respond.js 不起作用 -->
    <!--[if lt IE 9]>
    <script src="https://cdn.jsdelivr.net/npm/html5shiv@3.7.3/dist/html5shiv.min.js"></script>
    <script src="https://cdn.jsdelivr.net/npm/respond.js@1.4.2/dest/respond.min.js"></script>
    <![endif]-->
</head>
<body>
<div class="container" style="margin-top: 100px">
    <div class="row">
        <div class="col-md-4 col-xs-6 col-md-offset-4">
            <?php if (isset($n) && empty($n)) { ?>
                <div class="alert alert-danger" role="alert">
                    <button type="button" class="close" data-dismiss="alert" aria-label="Close"><span
                                aria-hidden="true">&times;</span></button>
                    <?php echo "用户名不能为空"; ?>
                </div>
            <?php } ?>

            <?php if (isset($p) && empty($p)) { ?>
                <div class="alert alert-danger" role="alert">
                    <button type="button" class="close" data-dismiss="alert" aria-label="Close"><span
                                aria-hidden="true">&times;</span></button>
                    <?php echo "密码不能为空"; ?>
                </div>
            <?php } ?>

            <div class="panel panel-primary">
                <div class="panel-heading">
                    <h3 class="panel-title"><span class="glyphicon glyphicon-glass"></span> 登录点餐系统</h3>
                </div>
                <div class="panel-body">

                    <form class="form-horizontal" action="dc.php">
                        <div class="form-group">
                            <label for="inputEmail3" class="col-md-3 control-label">用户名：</label>
                            <div class="col-md-9">
                                <input type="text" class="form-control" id="inputEmail3" name="username"
                                       placeholder="请输入用户名">
                            </div>
                        </div>
                        <div class="form-group">
                            <label for="inputPassword3" class="col-md-3 control-label">密码：</label>
                            <div class="col-md-9">
                                <input type="password" class="form-control" id="inputPassword3" name="pwd"
                                       placeholder="请输入密码">
                            </div>
                        </div>

                        <div class="form-group">
                            <div class="col-md-12" style="text-align:center">
                                <button type="submit" class="btn btn-primary">登录</button>
                            </div>
                        </div>
                    </form>
                </div>
            </div>
        </div>
    </div>
</div>


<!-- jQuery (Bootstrap 的所有 JavaScript 插件都依赖 jQuery，所以必须放在前边) -->
<script src="./js/jquery.min.js"></script>
<!-- 加载 Bootstrap 的所有 JavaScript 插件。你也可以根据需要只加载单个插件。 -->
<script src="./js/bootstrap.min.js"></script>
</body>
</html>
